class MallardDuck extends Duck {

    public MallardDuck(String color, double heavy) {
        super(color, heavy);
    }

    // 重写fly方法
    @Override
    public void fly() {
        System.out.println("绿头鸭扇动翅膀飞行");
    }

    // 重写quack方法
    @Override
    public void quack() {
        System.out.println("绿头鸭呱呱声");
    }

    // 重载setHeavy方法 - 添加验证逻辑
    public void setHeavy(double heavy, boolean validate) {
        if (validate && heavy > 0) {
            this.heavy = heavy;
            System.out.println("绿头鸭重量设置为: " + heavy + "kg");
        } else {
            System.out.println("重量设置无效");
        }
    }
}